<?php

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

namespace EasyActionPHP\Controller;

use EasyActionPHP\Core as Core;
use EasyActionPHP\Util as Util;

/**
 * AbstractFormBean - Classe abstrata representando um formulário web.
 *
 * @author Flavio de Vasconcellos Corrêa
 * @since 2007/06/04
 * @package EasyActionPHP
 * @subpackage Controller
 * @version $id$
 * @license http://www.gnu.org/copyleft/gpl.html GPL
 */
class AbstractFormBean extends Core\PBean {

    /**
     * Constructor
     */
    function __construct() {
        parent::__construct();
    }

    /**
     * Método abstrato para inicialização das propriedades do formulário.
     * @abstract
     * @access public
     */
    public function reset() {
        ;
    }

    /**
     * Método para popular os valores de um array no formulário.
     * @access public
     * @param Array vars
     */
    public function populate($vars) {
        if (!is_array($vars))
            return;
        foreach ($vars as $key => $value)
            $this->$key = $value;
    }

    /**
     * 	Retorna o nome dos campos do formulário.
     * @access public
     */
    public function getFieldValues() {
        return get_object_vars($this);
    }

    /**
     * Método abstrato para validação do formulário.
     * @abstract
     * @access public
     * @return ActionErrors
     */
    public function validate() {
        return new Util\ActionErrors();
    }

}

?>